< previous page page_4 next page >

Page 4
Whenever you want to draw something, you must determine where the drawing will be displayed. To do that, you need to understand how Visual Basic measures drawing coordinates. Each point on a form, picture box, or printer object has an X and a Y coordinate. By default, the X coordinate represents the distance from the left edge of the drawing area to the point, and the Y coordinate represents the distance from the top edge of the drawing area to the point. Figure 1.1 shows how the X and Y coordinates of a point relate to the drawing area.
Visual Basic provides several standard coordinate systems for your convenience. You select one of these systems by setting the drawing object's ScaleMode property.
The many different scales available in Visual Basic support flexibility in your graphic programming. You select one of these scales by setting the drawing object's ScaleMode property to one of the values in Table 1.1. The units in this list are specified in logical inches. A logical inch is an inch as it is theoretically displayed on a printer. Its length on your actual monitor or printer depends on your hardware and is probably not exactly one real inch.
In all of these scale modes, the upper left corner of the drawing area has coordinates (0, 0), and other coordinate values increase to the left and down.
By default, Visual Basic uses the vbTwips ScaleMode. This coordinate system gives sufficient precision for many applications, but sometimes another system is more convenient. If you want to draw a grid with lines every half inch, you may find it easier to work in inches.
Many advanced graphic techniques described in later chapters use Windows Application Programming Interface (API) functions. These functions always measure coordinates in pixels. If you use API functions in a drawing area, you may want to set the drawing area's ScaleMode to vbPixels. Then you will not need to convert back and forth between pixels for the API functions and whatever other scale you use for Visual Basic drawing commands. It is also usually easier to work with pixels when a program needs exact control over every pixel.
The vbCharacters coordinate system is the only one in which the horizontal and vertical units are not the same length. The coordinate values are roughly the size of a 12-point character, so they make aligning 12-point text in rows and columns easier. For example,
z0024-01.gif
Figure 1.1
The default Visual Basic coordinate system.

 
< previous page page_4 next page >